#ifndef AUTHENTICATION_H
#define AUTHENTICATION_H

#include "User.h"

/*!
 * @class Authentication
 * @brief Manages user login and returns the current user.
 *
 * The Authentication is a singleton class that manages user login
 * information. Once a user is logged in using the login() function, any class
 * can access that user by obtaining the Authentication instance using
 * getInstance() and then get the user using getUser() on the instance
 *
 */

class Authentication
{
public:
    /*!
     * Checks user database for user with username and password.
     * @return True if user found, false if not.
     */
    bool login(QString username, QString password);

    /*!
     * Sets current patient.
     * @return True if patient found in database, otherwise false.
     * @note This is used so doctor and nurse users can view or edit a
     *       particular patient's info.
     */
    bool setPatient(int userId);

    /*!
     * Gets currently logged in user.
     * @return User instance if a user is logged in (using login()) or NULL if
     *         not.
     */
    User * getUser();

    /*!
     * Gets current patient.
     * @return True if patient found in database, otherwise false.
     * @note This is used so doctor and nurse users can view or edit a
     *       particular patient's info.
     */
    User * getPatient();

    /*! Returns singleton instance of the Authentication class. */
    static Authentication * getInstance();

private:
    Authentication();
    ~Authentication();

    User *currentUser, *extraUser;

    static Authentication *authInst;
};

#endif // AUTHENTICATION_H
